import { Skeleton } from 'antd';
import { useMeStore } from '../../store/me';
import { Navigate } from 'react-router-dom';
import UsersTable from './UsersTable';
import MaybeABug from '../../components/MaybeABug';

export default function UsersPage() {
  const {
    status: { state },
  } = useMeStore();

  switch (state) {
    case 'AUTHED':
      return <UsersTable />;
    case 'LOADING':
      return <Skeleton loading />;
    case 'UNAUTHED':
      return <Navigate to="/login" />;
    default:
      return <MaybeABug message={`Unexpected me store state: '${state}'.`} />;
  }
}
